/**
*@author Ken 
*@version 2012 - 02 - 12 
// Package for board
// Entity class for storing data only 
// It should be no print out method
//******************************************
*@author Ming 
*@version 14/3/2012
*Modifications: Edited the constructor of the class 
//*******************************************/

package board;
import cell.*;
public class Board {
	
	/**
	 * @param args
	 */
	
	/** 2D array to build a board
	// the board is 21 x 21 due to max player is 6
	// So the width and the height is 9+6*2*/
	private Cell[] cellBoard = new Cell[28];
	private String[][] gameBoard = new String[21][21];
	
	/**to count which cell contain how many player*/
	private int[] cellArr = new int[28];
	
	/** an string array to hold what is it in the cell
	//private String[] cellType = new String[28];*/
	

	public Cell[] setCellBoard(){
		return this.cellBoard;
	}

	/** Constructor	*/
	public Board() {
		/** Preset the value 
		// right now it is just the board
		// no Player exist in the board*/
		for(int i =0; i< 21 ; i++) {
			for(int j=0; j<21; j++ ) {
				switch(i) {
					/** line 7*/
					case (6):
						/** in between and including 6 to 13*/
						if(j >= 6 && j <=13) //x-axis
							gameBoard[i][j] = "____";
						else
							gameBoard[i][j] = "    ";
						break;
						
					/** line 9 to 13*/
					case (8):
						if(j == 6 )
							gameBoard[i][j] = "|_E_";
						else if(j == 13)
							gameBoard[i][j] = "|SA_";
						else if(j == 7 || j == 14)
							gameBoard[i][j] = "|   ";
						else
							gameBoard[i][j] = "    ";
						break;
						
					case (10):
					case (12):	
						if(j == 6 )
							gameBoard[i][j] = "|_E_";
						else if(j == 7 || j == 14)
							gameBoard[i][j] = "|   ";
						else if (j == 13)
							gameBoard[i][j] = "|SA_";
						else
							gameBoard[i][j] = "    ";
						break;
						
					case (9):
						if(j == 6 )
							gameBoard[i][j] = "|_M_";
						else if(j == 13)
							gameBoard[i][j] = "|_E_";
						else if(j == 7 || j == 14)
							gameBoard[i][j] = "|   ";
						else if(i == 11 && j == 6)
							gameBoard[i][j] = "|SA_";
						else
							gameBoard[i][j] = "    ";
						break;
					
					case (11):
						if(j == 6 )
							gameBoard[i][j] = "|_+_";
						else if(j == 13)
							gameBoard[i][j] = "|_M_";
						else if(j == 7 || j == 14)
							gameBoard[i][j] = "|   ";
						else if(i == 11 && j == 6)
							gameBoard[i][j] = "|SA_";
						else
							gameBoard[i][j] = "    ";
						break;
					
					/** line 14*/
					case (13):
						if(j == 6 )
							gameBoard[i][j] = "|GH_";
						else if(j == 13)
							gameBoard[i][j] = "|_E_";
						else if(j == 7 )
							gameBoard[i][j] = "|___";
						else if(j == 14)
							gameBoard[i][j] = "|   ";
						else if(j >=8 && j <=12)
							gameBoard[i][j] = "____";
						else
							gameBoard[i][j] = "    ";
						break;
					/** line 8 and 15 lower bound of the board*/
					
					case (7):	
						if(j >= 6 && j <=13) { /**the 1st row*/
							if(j%2==1)
								gameBoard[i][j] = "|_E_";
							else{
								gameBoard[i][6] = "|_H_";
								gameBoard[i][8] = "|_F_";
								gameBoard[i][10]= "|SA_";
								gameBoard[i][12] = "|_A_";
							}
						}
						else if(j == 14)
							gameBoard[i][j] = "|   ";
						else
							gameBoard[i][j] = "    ";
						break;
					
					case(14):
						if(j >= 6 && j <=13) {
							if(j%2==0)
								gameBoard[i][j] = "|_E_";
							else if (j == 7 || j == 11)
								gameBoard[i][j] = "|SA_";
							else{
								gameBoard[i][13] = "|_A_";
								gameBoard[i][9] = "|_F_";
							}
						}
						else if(j == 14)
							gameBoard[i][j] = "|   ";
						else
							gameBoard[i][j] = "    ";
						break;
					default:
						gameBoard[i][j] = "    ";
				}
			}
		}
		
		/** Each cell contain zero player at the beginning*/
		for (int i=0; i<28; i++) {
			cellArr[i] = 0;
		}
	
		for(int i=0; i<28; i++) {
			if(i%2 == 1){
				if (i != 11)
					cellBoard[i] = new EventCell(i);
				else
					cellBoard[i] = new MagicCell(i);
			}
			else if(i == 4 || i == 8 || i == 10 || i == 12 || i == 16 || i == 20)
				cellBoard[i] = new SayActCell(i);
			else if(i == 2 || i == 18)
				cellBoard[i] = new FestivalCell(i);
			else if(i == 6 || i == 14)
				cellBoard[i] = new AccidentCell(i);
			else if(i == 22)
				cellBoard[i] = new GoToHospitalCell(i);
			else if(i == 24)
				cellBoard[i] = new HospitalCell(i);
			else if(i == 26)
				cellBoard[i] = new MagicCell(i);
		}
	}
	
	public int[] getCellArr() {
		return cellArr;
	}

	public void setCellArr(int[] cellArr) {
		this.cellArr = cellArr;
	}

	public String[][] getGameBoard() {
		return gameBoard;
	}

	public void setGameBoard(String[][] gameBoard) {
		this.gameBoard = gameBoard;
	}
}